
var showCount = 10;
var currentPage = 0;
var totalResult = 156;
var base_path ="/uthink-backstage"; 

$(function() {
	initPager();
});		

function initPager(){
	$("#Pagination").pagination(totalResult, {
		callback: function(new_page_index, pagination_container){
			var oldLocation = location.href;
			var pa = "currentPage=" + (new_page_index+1);
			var shoC = "showCount=" + showCount;
			var index = oldLocation.lastIndexOf("?");
			if (index == -1){
				location.href = oldLocation + "?" + pa + "&" + shoC;
			}else if (oldLocation.indexOf("currentPage") == -1){
				location.href = oldLocation + "&" + pa;
			}else if (oldLocation.indexOf("showCount") == -1){
				location.href = oldLocation + "&" + shoC;
			}else{
				var temp = oldLocation.replace(/currentPage=\d+/, pa);
				var newLocation = temp.replace(/showCount=\d+/, shoC);
				location.href = newLocation;
			}
			return false;
		},
		items_per_page:showCount, 
		load_first_page:false,
		prev_text:'上一页',
		next_text:'下一页',
		ellipse_text:'...',
		num_edge_entries:1,
		num_display_entries:5,
		current_page:currentPage,
	});
}

	/*
	重置
	*/
	function the_reset(){
		$("#search-form input[type='text']").val('');
		$("#search-form select").val(-1);
	}
	

	/*添加*/
	function t_member_add(title, url, w, h) {
		layer_show(title, url, w, h);
	}

	/*编辑*/
	function t_member_edit(obj,id,w,h){
		var edit_page = base_path+"/backstage/member-add-pre?id="+id;
		var index = layer.open({
			type: 2,
			title: "编辑",
			content: edit_page
		});
		layer.full(index);
	}
	
	/*查看*/
	function t_member_show(obj,id,w,h){
		var show_page = base_path+"/backstage/member_show?memberid="+id;
		var index = layer.open({
			type: 2,
			title: "用户详情",
			content: show_page
		});
		layer.full(index);
	}

	/*删除*/
	function t_member_delete(obj,id){
		layer.confirm('确认 删除用户相关所有信息，身份，核伙人，企业主，自媒体，积分等相关？', {
			btn: ['确认','取消'], 
			shade: false
		},
		function(){
			$.ajax({
				type : "POST",
				url : base_path+"/backstage/member-delete",
				data : "id=" + id,
				error : function() {
					layer.msg('操作失败', {
						icon : 5,
						time : 1000
					});
				},
				success : function(msg) {
					layer.msg('已删除 ' + msg.information, {
						icon : 6,
						time : 1000
					});
					$(obj).parents("body").find(".btn-refresh").click();
				}
			});
		}, function() {
			layer.msg('未删除', {
				icon : 5,
				time : 1000
			});
		});
	}
	
	function verifyInfo(userid,verifytype){
		var url = "";
		if(verifytype=="idcard"){//身份认证查看
			var url = base_path+"/backstage/member_idcard_detail?userid="+userid;
		}else if(verifytype=="partner"){//合伙人认证查看
			var url = base_path+"/backstage/member_partner_detail?userid="+userid;
		}else if(verifytype=="entrepreneur"){//企业主认证查看
			var url = base_path+"/backstage/member_entrepreneur_detail?userid="+userid;
		}else if(verifytype=="media"){//自媒体认证查看
			var url = base_path+"/backstage/member_media_detail?userid="+userid;
		}
		var index = layer.open({
			type: 2,
			title: "认证信息",
			content: url
		});
		layer.full(index);
	}
	

